package com.some;

import java.util.Arrays;
import java.util.Scanner;

public class WeBank01 {
    public String maxValue(int[] tmp) {
        int length = tmp.length - 1;
        Arrays.sort(tmp);
        int[] nums = new int[3];
        nums[0] = tmp[length];
        nums[1] = tmp[length - 1];
        nums[2] = tmp[length - 2];
        String[] strings = new String[nums.length];
        int a = 0;
        for (int num : nums) {
            strings[a++] = String.valueOf(num);
        }
        Arrays.sort(strings, (x, y) -> (y + x).compareTo(x + y));

        StringBuilder stringBuilder = new StringBuilder();
        for (String s : strings) {
            stringBuilder.append(s);
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        WeBank01 weBank01 = new WeBank01();
        System.out.println(weBank01.maxValue(nums));
    }
}
